<template>
	<div class="PDF">
		<span style="color: red">操作说明：</span>点“加盖印章”按钮即可，插入印章时的用户名为：李志，密码默认为：111111。
		<!-- 此div用来加载PageOffice客户端控件，其中div的高宽及位置就决定了控件的大小及位置 -->
		<div style="width:auto; height:900px;" v-html="poHtmlCode"></div>
	</div>
</template>

<script>
import request from '@/utils/request'
export default {
	name: "Word",
	data() {
		return {
			poHtmlCode: "",
		};
	},
	created: function () {
		// 请求后端打开文件
		this.openFile().then(response => {
			this.poHtmlCode = response;
		});
	},
	methods: {
		//控件中的一些常用方法都在这里调用，比如保存，打印等等
		Save() {
			pdfctrl.SaveFilePage = "/InsertSeal/PDF/AddSeal/save?savePath=/InsertSeal/PDF/AddSeal1/"
			pdfctrl.WebSave();
		},
		InsertSeal() {
			try {
				pdfctrl.zoomseal.AddSeal();
			} catch (e) {
			}
		},
		//修改密码
		ChangePsw() {
			pdfctrl.zoomseal.ShowSettingsBox();
		},
		AfterDocumentOpened() {
			//alert(document.getElementById("PDFCtrl1").Caption);
		},
		SetBookmarks() {
			pdfctrl.BookmarksVisible = pdfctrl.BookmarksVisible;
		},
		PrintFile() {
			pdfctrl.ShowDialog(4);
		},
		SwitchFullScreen() {
			pdfctrl.FullScreen = !pdfctrl.FullScreen;
		},
		SetPageReal() {
			pdfctrl.SetPageFit(1);
		},
		SetPageFit() {
			pdfctrl.SetPageFit(2);
		},
		SetPageWidth() {
			pdfctrl.SetPageFit(3);
		},
		ZoomIn() {
			pdfctrl.ZoomIn();
		},
		ZoomOut() {
			pdfctrl.ZoomOut();
		},
		FirstPage() {
			pdfctrl.GoToFirstPage();
		},
		PreviousPage() {
			pdfctrl.GoToPreviousPage();
		},
		NextPage() {
			pdfctrl.GoToNextPage();
		},
		LastPage() {
			pdfctrl.GoToLastPage();
		},
		SetRotateRight() {
			pdfctrl.RotateRight();
		},
		SetRotateLeft() {
			pdfctrl.RotateLeft();
		},
		OnPDFCtrlInit() {
			pdfctrl.AddCustomToolButton("保存", "Save()", 6);
			pdfctrl.AddCustomToolButton("盖章", "InsertSeal()", 0);
			//PDF的初始化事件回调函数，您可以在这里添加自定义按钮
			if (("linux") != (pdfctrl.ClientOS)) {
				pdfctrl.AddCustomToolButton("修改密码", "ChangePsw()", 0);
				pdfctrl.AddCustomToolButton("隐藏/显示书签", "SetBookmarks()", 0);
			}
			pdfctrl.AddCustomToolButton("打印", "PrintFile()", 6);
			pdfctrl.AddCustomToolButton("-", "", 0);
			pdfctrl.AddCustomToolButton("实际大小", "SetPageReal()", 16);
			pdfctrl.AddCustomToolButton("适合页面", "SetPageFit()", 17);
			pdfctrl.AddCustomToolButton("适合宽度", "SetPageWidth()", 18);
			pdfctrl.AddCustomToolButton("缩小", "ZoomOut()", 17);
			pdfctrl.AddCustomToolButton("放大", "ZoomIn()", 18);
			pdfctrl.AddCustomToolButton("-", "", 0);
			pdfctrl.AddCustomToolButton("首页", "FirstPage()", 8);
			pdfctrl.AddCustomToolButton("上一页", "PreviousPage()", 9);
			pdfctrl.AddCustomToolButton("下一页", "NextPage()", 10);
			pdfctrl.AddCustomToolButton("尾页", "LastPage()", 11);
			pdfctrl.AddCustomToolButton("-", "", 0);
			pdfctrl.AddCustomToolButton("向左旋转90度", "SetRotateLeft()", 12);
			pdfctrl.AddCustomToolButton("向右旋转90度", "SetRotateRight()", 13);
		},
		openFile() {
			return request({
				url: '/InsertSeal/PDF/AddSeal/PDF1',
				method: 'get',
			})
		}
	},
	mounted: function () {
		//将当前页面methods中定义的函数挂载到PageOffice控件，例如控件触发的事件、自定义按钮触发的函数。
		window.POPageMounted = this;//此行必须
	}
}
</script>
